import request from "@/request/request.ts";
import { pageParamsInterface } from "@/views/product/trademark/interface/interface.ts";
import { responseTrademarkList, trademark, trademarkInfo } from "@/api/product/trademarkApi/interface.ts";

enum Enum {
  trademark = "/admin/product/baseTrademark",
  deleteTrademark = "/admin/product/baseTrademark/remove",
  addTrademark = "/admin/product/baseTrademark/save",
  updateTrademark = "/admin/product/baseTrademark/update"
}

/* 获取品牌的接口 */
export const fetchTrademarkListAPI: (pageParams: pageParamsInterface) => Promise<responseTrademarkList> = (pageParams: pageParamsInterface): Promise<responseTrademarkList> => {
  return request({
    url: `${Enum.trademark}/${pageParams.page}/${pageParams.limit}`,
    method: "GET",
  });
};

/* 删除品牌的接口 */
export const deleteTrademarkAPI: (id: number) => Promise<any> = (id: number): Promise<any> => {
  return request({
    url: `${Enum.deleteTrademark}/${id}`,
    method: "DELETE",
  });
};

/* 添加品牌的接口 */
export const addTrademarkAPI: (data: trademark) => Promise<any> = (data: trademark): Promise<any> => {
  return request({
    url: Enum.addTrademark,
    method: "POST",
    data,
  });
};

/* 修改品牌的接口 */
export const updateTrademarkAPI: (data: trademark) => Promise<any> = (data: trademarkInfo): Promise<any> => {
  return request({
    url: Enum.updateTrademark,
    method: "PUT",
    data,
  });
};
